import {defineConfig, loadEnv} from "vite";
// import vue from '@vitejs/plugin-vue'

const path = require('path')


export default defineConfig(({command, mode}) => {
    const env = loadEnv(mode, __dirname);
    console.log('env', env, mode, command)
    return {
        // plugins: [vue()],
        root: path.resolve(__dirname, 'src'),
        css: {
            /* CSS 预处理器 */
            preprocessorOptions: {
                scss: {
                    additionalData: `
                   
                    @import "@web/static/lib/bootstrap/scss/bootstrap.scss";
                    
                      
                      @import "@web/scss/utils.scss";
                    @import "@web/scss/primary_variables.scss";
                    @import "@web/scss/secondary_variables.scss";
                     @import "@web/core/datetime/datetime_picker.scss";
                     @import "@web/scss/functions.scss";
                    @import "@web/scss/ui.scss";
                    @import "@web/scss/ace.scss";
                    @import "@web/scss/base_frontend.scss";
                    @import "@web/scss/animation.scss";
                    @import "@web/scss/bs_mixins_overrides.scss";
                    @import "@web/scss/bootstrap_overridden.scss";
                  
                    
                    @import "@web/webclient/webclient.scss";
                    @import "@web/webclient/navbar/navbar.variables.scss";
                    @import "@web/webclient/navbar/navbar.scss";
                    @import "@web/webclient/user_menu/user_menu.scss";
                    @import "@web/webclient/loading_indicator/loading_indicator.scss";
                 
                    @import "@web/core/utils/transitions.scss";
                    @import "@web/core/utils/draggable_hook_builder.scss";
                    @import "@web/core/utils/nested_sortable.scss";
                    
                    @import "@web/core/avatar/avatar.variables.scss";
                    @import "@web/core/avatar/avatar.scss";
                    
                    @import "@web/core/select_menu/select_menu.scss";
                    @import "@web/core/dialog/dialog.scss";
                    @import "@web/core/dropdown/dropdown.scss";
                    @import "@web/core/tags_list/tags_list.scss";
                    @import "@web/core/ui/block_ui.scss";
                    @import "@web/core/colorlist/colorlist.scss";
                    @import "@web/core/file_upload/file_upload_progress_bar.scss";
                    @import "@web/core/file_upload/file_upload_progress_record.scss";
                    @import "@web/core/checkbox/checkbox.scss";
                    @import "@web/core/notebook/notebook.scss";
                    @import "@web/core/signature/name_and_signature.scss";
                    @import "@web/core/resizable_panel/resizable_panel.scss";
                    @import "@web/core/model_selector/model_selector.scss";
                    @import "@web/core/model_field_selector/model_field_selector.scss";
                    @import "@web/core/model_field_selector/model_field_selector_popover.scss";
                    @import "@web/core/dropdown/dropdown.scss";
                    @import "@web/core/dropdown/accordion_item.scss";
                    @import "@web/core/notifications/notification.variables.scss";
                    @import "@web/core/notifications/notification.scss";
                   
                    
                    @import "@web/core/tooltip/tooltip.scss";
                    
                  
                    
                     @import "@web/views/view.scss";
                     @import "@web/views/form/form.variables.scss";
                     @import "@web/views/form/form_controller.scss";
                     @import "@web/views/form/button_box/button_box.scss";
                     @import "@web/views/form/status_bar_buttons/status_bar_buttons.scss";
                     
                     
                     @import "@web/views/list/list_renderer.scss";
                     @import "@web/views/list/list_confirmation_dialog.scss";
                     
                     @import "@web/search/search_bar_menu/search_bar_menu.scss";
                     @import "@web/search/cog_menu/cog_menu.scss";
                    
                     @import "@web/views/view_components/animated_number.scss";
                     
                     @import "@web/views/list/list_confirmation_dialog.scss";
                     @import "@web/views/list/list_renderer.scss";
                     
                     @import "@web/views/fields/char/char_field.scss";
                     @import "@web/views/fields/badge/badge_field.scss";
                     @import "@web/views/fields/boolean_favorite/boolean_favorite_field.scss";
                     @import "@web/views/fields/color_picker/color_picker_field.scss";
                     @import "@web/views/fields/copy_clipboard/copy_clipboard_field.scss";
                     @import "@web/views/fields/datetime/datetime_field.scss";
                     @import "@web/views/fields/email/email_field.scss";
                     @import "@web/views/fields/html/html_field.scss";
                     @import "@web/views/fields/iframe_wrapper/iframe_wrapper_field";
                     @import "@web/views/fields/image/image_field";
                     @import "@web/views/fields/journal_dashboard_graph/journal_dashboard_graph_field";
                     @import "@web/views/fields/many2many_binary/many2many_binary_field";
                     @import "@web/views/fields/many2many_tags/many2many_tags_field";
                     @import "@web/views/fields/many2many_tags_avatar/many2many_tags_avatar_field";
                     @import "@web/views/fields/many2one/many2one_field";
                     @import "@web/views/fields/many2one_avatar/many2one_avatar_field";
                     @import "@web/views/fields/monetary/monetary_field";
                     @import "@web/views/fields/pdf_viewer/pdf_viewer_field";
                     @import "@web/views/fields/percent_pie/percent_pie_field";
                     @import "@web/views/fields/phone/phone_field";
                     @import "@web/views/fields/priority/priority_field";
                     @import "@web/views/fields/progress_bar/progress_bar_field";
                     @import "@web/views/fields/radio/radio_field";
                     @import "@web/views/fields/selection/selection_field";
                     @import "@web/views/fields/signature/signature_field";
                     @import "@web/views/fields/state_selection/state_selection_field";
                     @import "@web/views/fields/statusbar/statusbar_field.variables";
                     @import "@web/views/fields/statusbar/statusbar_field";
                     @import "@web/views/fields/text/text_field";
                     @import "@web/views/fields/url/url_field";
                
           
                    `,
                }
            },
        },

        resolve: {
            alias: {
                "@web": path.resolve("./src"), // 相对路径别名配置，使用 @ 代替 src
                '~bootstrap': path.resolve(__dirname, 'node_modules/bootstrap'),
            },

        },
        server: {
            port: 8080,
            hot: true,
            proxy: {
                '/web/': {
                    target: 'http://127.0.0.1:8169',
                    // changeOrigin: true, // 是否将请求header中的origin修改为目标地址
                },

            },

        },


    }
})
